package com.sh.data.engine.domain.base.service;

import com.sh.data.engine.domain.base.model.ChunkFileUploadDomain;
import com.sh.data.engine.domain.base.model.FileUploadResultDomain;
import com.sh.data.engine.domain.base.model.FileUrlDomain;
import com.sh.data.engine.domain.base.model.param.ChunkFileUploadParam;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;
import java.io.File;

/**
 * @author: mengzheng.mhc
 * @date: 2024/6/11 9:22
 */
public interface FileService {

    FileUploadResultDomain upload(MultipartFile multipartFile) throws Exception;

    FileUploadResultDomain upload(MultipartFile multipartFile, boolean uuidFileName) throws Exception;

    /**
     * @param multipartFile
     * @param fileRelativeDirPath 参数格式 f/f/f （前后不需要/）
     * @return
     * @throws Exception
     */
    FileUploadResultDomain upload(MultipartFile multipartFile, String fileRelativeDirPath)
        throws Exception;

    FileUploadResultDomain upload(
        MultipartFile multipartFile, String fileRelativeDirPath, boolean uuidFileName)
        throws Exception;

    FileUploadResultDomain uploadHiveSite(
        MultipartFile multipartFile, String fileRelativeDirPath, boolean uuidFileName)
        throws Exception;

    /**
     * 分片上传
     *
     * @param request
     * @param param
     * @return
     */
    ChunkFileUploadDomain uploadByChunk(HttpServletRequest request, ChunkFileUploadParam param);

    File getFileByPath(String filePath);

    FileUrlDomain getFileUrlByPath(String filePath, HttpServletRequest request);
}
